package cl.edinet.agencialinea3.web.listener;

import cl.edinet.agencialinea3.ejb.service.AgenciaLineaServiceRemote;
import cl.edinet.leela2.web.listener.AbstractLeelaListener;
import cl.edinet.leela2.web.servlet.filter.LeelaFilterRoutingServlet;
import javax.ejb.EJB;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * Web application lifecycle listener.
 *
 * @author mauricio
 */
@WebListener
public class AgenciaContextListener extends AbstractLeelaListener<AgenciaLineaServiceRemote> implements ServletContextListener {

    @EJB
    private AgenciaLineaServiceRemote agenciaLineaServiceRemote;

    @Override
    public void contextInitialized(ServletContextEvent sce) {

        /*
         * LEELA
         */
        LeelaFilterRoutingServlet.registerClassLoader(getClass().getClassLoader());
        LeelaFilterRoutingServlet.initControllerMap(sce.getServletContext());
        super.registerRemote(sce, agenciaLineaServiceRemote);

    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        agenciaLineaServiceRemote = null;
    }
}
